<?php
class informationController extends userController {

	public function index() {
		$user_info=model('user_list')->info($this->user_id);
		$this->province_list=model('region')->region_list(1,1);
        $this->city_list=model('region')->region_list($user_info['province'],2);
		$this->show();
	}



	public function info_save() {
		//数据过滤
		$data=in($_POST);
		//表单验证
		$user_info=model('user_list')->info($this->user_id);
		if(md5($data['old_password'])<>$user_info['password']){
			$this->msg('原始密码输入错误！',0);
		}

		if(!Check::userName($data['nicename'],2,20,'/^[x4E00-x9FA5\xf900-xfa2d\w\s]+$/u')||empty($data['nicename'])){
			$this->msg('昵称只支持2~6位中文英文数字下划线',0);
		}

		if(!Check::email($data['email'])||empty($data['email'])){
			$this->msg('邮箱地址输入不正确',0);
		}

        if(!Check::mobile($data['tel'])||empty($data['tel'])){
			$this->msg('手机号码输入不正确',0);
		}

		if(!Check::userName($data['address'],3,200,'/^[x4E00-x9FA5\xf900-xfa2d\w\.\s]+$/u')||empty($data['address'])){
			$this->msg('请填写正确的地址，不能有特殊符号',0);
		}

		if(!Check::userName($data['qq'],4,12,'/^[1-9][0-9]{4,}$/')){
			$this->msg('qq号码填写不正确',0);
		}

		unset($data['username']);
		unset($data['gid']);
		$data['uid']=$this->user_id;

		//入库操作
		model('user_list')->edit($data);
		$this->msg('资料保存成功!');
	}

	public function password() {
		$this->show();
	}

	public function pass_save() {
		//数据过滤
		$data=in($_POST);
		$user_info=model('user_list')->info($this->user_id);

		if(md5($data['old_password'])<>$user_info['password']){
			$this->msg('原始密码输入错误！',0);
		}

		if(!Check::userName($data['password'],6,16,'/[\w\W]+/')||empty($data['password'])){
			$this->msg('密码只支持6~16位字符',0);
		}

		if($data['password']<>$data['password2']){
            $this->msg('两次密码输入不同！',0);
        }

        $data_array=array();
        $data_array['password']=md5($data['password']);
        $data_array['uid']=$this->user_id;
        //入库操作
		model('user_list')->edit($data_array);
		$this->msg('密码修改成功!');

	}

	

}